<style>
.tab-pane{border:1px solid #cccccc}
</style>
<link rel="stylesheet" type="text/css" href="/simpletree/js/tree_themes/SimpleTree.css"/>
<script type="text/javascript" src="/simpletree/js/SimpleTree.js"></script>
<script type="text/javascript">
$(function(){
	$(".st_tree").SimpleTree({
		click:function(a){
			if(!$(a).attr("hasChild"))
				alert($(a).attr("ref"));
		}
	});
});
</script>
<div class="container-fluid">
   <div class="row-fluid">
     <div class="span2">
			   <ul class="nav nav-tabs nav-stacked">
				<li><a href="/letter/index">未处理消息</a></li>
				<li class="active"><a href="/letter/send">发送消息</a></li>
				<!--<li><a href="/letter/recycle">回收站</a></li>-->
				<li><a href="/letter/history">历史消息</a></li>
            </ul>					   
		</div>
     <div class="span7" style="position: relative">
			<form id='form' action="/letter/send" method="post" enctype="multipart/form-data">			
					<div style="font-size:21px; ">收件对象<br />
						    <div class="span10" type="text" placeholder=".span5" id='touser' style='border-bottom:1px solid #000'></div>
							<div style='display:none' id='hidtoids'></div>
						    <input type='hidden' name='toids' id='toids'>
					</div>
						<div style='clear:both'></div>
						<div>
                        <br />
						<fieldset ><legend>私信内容</legend>
							<div class="tabbable"> 
										<ul class="nav nav-tabs">
												<li class="active"><a href="#tab1" data-toggle="tab" onclick='cleartab(1)'>文字</a></li>
												<li><a href="#tab2" data-toggle="tab" onclick='cleartab(2)'>图片</a></li>
										</ul>
										<div class="tab-content">
												<div class="tab-pane active" id="tab1">
												   <textarea id="content" name="content" style="width:98%;height:100px;1px solid red" data-required></textarea>
												</div>
												<div class="tab-pane" id="tab2">
												  <input type='file' name='pic' id='pic' data-required="true">
												</div>
                                                
												<div>
                                                <br />
												<input type="submit" class="btn btn-primary" value='提交'>
												</div>						
										</div>
							</div>
						</fieldset>
                       </div>						
			</form>				
       </div> 

     <div class="span3">	 
		<div class="st_tree">
			<ul>
			     <li>通讯录</li>
				 <*foreach from=$result item=rs*>
				 <li><a onclick='getsch("<*$rs.groupid*>")'><*$rs.groupname*></a></li>
                  <ul id='two_<*$rs.groupid*>'></ul>
				 <*/foreach*>
			
			</ul>
		</div>
	</div>
    </div>
</div> 
<script>
function getsch(gid){
    $.get("/letter/getsch/groupid/"+gid,
	function(data){
	  $('#two_'+gid).empty();
	  $('#two_'+gid).append(data);
	});
}
function getcla(ids){ 
   var obj = eval('('+'ids'+')');
   $('.three').hide();
   $('#three_'+obj.sid).show(); 
   var obj = eval('('+'ids'+')');
   $('#sch'+obj.sid+'>ul').empty();
   $.get("/letter/getcla/gid/"+obj.gid+"/sid/"+obj.sid,
   function(data){
      $('#three_'+obj.sid).empty();
	  $('#three_'+obj.sid).append(data);
   });   
  
}
function gettea(ids){ 
   var obj = eval('('+'ids'+')');
   //alert(obj.cid);exit;
   $('.four').hide();
   $('#four_'+obj.cid).show(); 
   var obj = eval('('+'ids'+')');
   $('#tea'+obj.cid+'>ul').empty();
   $.get("/letter/getsendtea/gid/"+obj.gid+"/cid/"+obj.cid,
   function(data){
      $('#four_'+obj.cid).empty();
	  $('#four_'+obj.cid).append(data);
   });   
  
}
function addtouser(str){
  var obj = eval('('+'str'+')'); 
  var idstr = $('#toids').val();
  var strs = new Array(); //定义一数组
  strs = idstr.split(",");   //字符分割    
  if(strs.length>1){
    if(($.inArray(obj.uid,strs))<0){
	  $('#hidtoids').append(obj.teacherclassid+",");
      $('#toids').val($('#hidtoids').text());
      $('#touser').append(obj.teachername+",");
	}
  }else{
     $('#hidtoids').append(obj.teacherclassid+",");
     $('#toids').val($('#hidtoids').text());
     $('#touser').append(obj.teachername+",");
  }  
}
function cleartab(id){
  if(id==1){
    $('#content').val('');
  }else{
    $('#pic').val('');
  }
}
$('#addpic').click(function(){
  $('.modal-body').append("<input type='file' name='pics[]' class='pic'>");
 })
$('#delpic').click(function(){
  $('.modal-body').empty();
  $('.modal-body').append('<input type="file" name="pics[]" class="pic">');
})


</script>
